#include "introscene.h"
#include "config.h"
#include "mypushbutton.h"
#include <QPainter>

IntroScene::IntroScene(QWidget *parent)
    : QWidget{parent}
{
    //初始化窗口大小
    setFixedSize(GAME_WIDTH,GAME_HEIGTH);

    //设置窗口标题
    setWindowTitle(GAME_TITLE);

    //加载图标
    setWindowIcon(QIcon(GAME_ICON));

    MyPushButton* backBtn = new MyPushButton(BTN_BACK);
    backBtn->setParent(this);
    backBtn->move(this->width()-backBtn->width(),this->height()-backBtn->height());
    connect(backBtn,&MyPushButton::clicked,[=](){
        //发送点击返回按钮的信号
        emit this->IntroSceneBack();

        this->hide();//自身隐藏
    });
}

void IntroScene::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QPixmap pix;
    pix.load(INTRO_PATH);
    painter.drawPixmap(0,0,this->width(),this->height(),pix);
}
